package com.mybatis.mapper.impl;

import com.mybatis.domain.SysRole;
import com.mybatis.mapper.RoleMapper;
import com.mybatis.mapper.UsersMapper;
import com.mybatis.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class RoleMapperImpl implements RoleMapper {

    SqlSession session;

    @Override
    public List<SysRole> list() {
        try{
            session = MybatisUtil.getSqlSession();    // 获取session
            return session.getMapper(RoleMapper.class).list();  // 返回结果集
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MybatisUtil.closeSession(session);
        }
        return null;
    }

    public static void main(String[] args) {
        List<SysRole> roleList = new RoleMapperImpl().list();
        for (SysRole item:roleList ) {
            System.out.println(item);
        }
    }
}
